import { ApiProperty, ApiPropertyOptional } from '@midwayjs/swagger'
import { Rule, RuleType } from '@midwayjs/validate'

import { PageDTO } from '@/dto'

/**
 * 查找岗位分页传输对象
 */
export class FindPostPageDTO extends PageDTO implements IFindPostPageDTO {
  @ApiPropertyOptional({ description: '岗位编码' })
  @Rule(RuleType.string().empty(''))
  postCode: string

  @ApiPropertyOptional({ description: '岗位名称' })
  @Rule(RuleType.string().empty(''))
  postName: string

  @ApiPropertyOptional({ description: '状态' })
  @Rule(RuleType.string().empty(''))
  status: string
}

/**
 * 添加岗位传输对象
 */
export class CreatePostDTO implements ICreatePostDTO {
  @ApiProperty({ description: '岗位名称' })
  @Rule(RuleType.string().required().error(new Error('岗位名称不能为空')))
  postName: string

  @ApiProperty({ description: '岗位编码' })
  @Rule(RuleType.string().required().error(new Error('岗位编码不能为空')))
  postCode: string

  @ApiProperty({ description: '显示顺序' })
  @Rule(RuleType.number().required().error(new Error('岗位顺序不能为空')))
  postSort: number

  @ApiPropertyOptional({ description: '状态' })
  @Rule(RuleType.string().empty(''))
  status: string

  @ApiPropertyOptional({ description: '备注' })
  @Rule(RuleType.string().empty(''))
  remark: string
}

/**
 *  更新岗位传输对象
 */
export class UpdatePostDTO extends CreatePostDTO {}
